# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=xpire-crossdomain-scanner
pkgver=1.0cb8d3b
pkgrel=5
groups=('blackarch' 'blackarch-scanner')
pkgdesc='Scans crossdomain.xml policies for expired domain names.'
arch=('any')
url='https://github.com/mandatoryprogrammer/xpire-crossdomain-scanner'
license=('GPL2')
depends=('python2' 'python2-tldextract' 'python2-defusedxml' 'python2-netaddr'
         'python2-requests' 'python2-python-whois')
makedepends=('git')
source=('git+https://github.com/mandatoryprogrammer/xpire-crossdomain-scanner.git')
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md requirements.txt
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE requirements.txt

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 crossdomain-scan.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

